﻿namespace GSMock.Config
{
    using System;
    using System.Configuration;

    public class Configuration : ConfigurationSection
    {
        [ConfigurationProperty("collections")]
        public CollectionsCollection Collections
        {
            get
            {
                return this["collections"] as CollectionsCollection;
            }
        }

        [ConfigurationProperty("stylesheets")]
        public StyleSheetsCollection Stylesheets
        {
            get
            {
                return this["stylesheets"] as StyleSheetsCollection;
            }
        }

        public static Configuration GetConfig()
        {
            string configurationSectionName = "gsmock.config";
            
            Configuration config = ConfigurationManager.GetSection(configurationSectionName) as Configuration;

            if (config == null)
            {
                throw new ApplicationException(
                    string.Format("Unable to load configuration, cannot find configuration section \"{0}\".", configurationSectionName));
            }

            return config;
        }

    }
}
